<?php
    require("./Utils.php");

    $post = getJsonParamter();
    $conn = getConnection();

    $id = $post['id'];
    $name = $post['name'];
    $type_id = $post['type_id'];
    $kind_id = $post['kind_id'];
    $intro = $post['intro'];
    $price = $post['price'];
    $stock = $post['stock'];
    $added = $post['added'];

    $sql = "UPDATE pet
            SET name = ?, type_id = ?, kind_id = ?, intro = ?, price = ?, stock = ?, added = ?
            WHERE id = ?";

    $result = execute($conn, $sql, $name, $type_id, $kind_id, $intro, $price, $stock, $added, $id);

    if($result){
        getJson(200, '修改成功', null);
    }else{
        getJson(500, '修改失败', null);
    }
?>